<?
	require_once('init.php');
	require_once('dataModel.php');
	
	if(!$_GET['GID'])
	{
		$GID = 0;
	}
	else
	{
		$GID = $_GET['GID'];
	}
    
	$strGID=$_SESSION["ViewGoodsID"];
	
	$strGID=str_replace( $GID."," ,"",$strGID);
	$strGID= $GID.",".$strGID;
	$arraystrGID=explode(",", $strGID);

	$sql = "select g.id,g.goodsid,g.colorid,g.sizeid,g.adviceprice,g.".$strLanguage_Goods.",g.".$strLanguage_GoodsRemark.",g.pic1,g.pic2,g.pic3,g.pic4,g.pic5,g.pic6,c.".$strLanguage_Color." ";
	$sql.= "from goods g left join color c on c.id=g.colorid ";
	$sql.= "where g.id='".$GID."' limit 0,1";
	$db = MySQL::getInstance('','r-w'); 
	$rsgoods = $db->fetch($db->query($sql));
	
	$CID=$rsgoods["colorid"];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
	<meta http-equiv="Content-Type" content="text/html; charset=<?=$lng_characset;?>" />
	<meta name="keywords" content="GreenCity,Shoes,Ь" />
	<meta name="description" content="GreenCity" />
	<meta name="copyright" content="Copyright (c) 2011 www.GreenCity.com All Rights Reserved." />
	<meta name="publisher" content="Copyright (c) 2010 www.GreenCity.com All Rights Reserved." />
	<meta name="author" content="GreenCity Team" />
	
	<TITLE><?=$AllPageTitle;?></TITLE> 

	<link href="css/main.css" rel="stylesheet" type="text/css" />
	<link href="css/Buttonstyle.css" rel="stylesheet" type="text/css" />
	<link href="css/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />
	<link href="css/body2.css" rel="stylesheet" type="text/css" />

	<!--script type="text/javascript" src="Scripts/jquery.js"></script-->
	<!--script type="text/javascript" src="Scripts/jquery.jqzoom.js"></script-->
	
	<? include("alljs.php"); ?>
	
	<script language="javascript" type="text/javascript">
		$(document).ready(function() 
		{
    		$('.goodsdetail_bigpic').cycle(
    		{
				fx: 'scrollLeft',   //fade,scrollUp,scrollDown,scrollLeft,scrollRight,zoom,turnUp
			                        //turnDown,turnLeft,turnRight,curtainX,zoom';
//			    	timeout:     3000,    
				sync:  false,
		   			delay: -2000
			});
			
		});
		
		function ChangeNum()
		{
			value=$("#txtnum").attr("value"); 
			$("#txtnum").attr("value",value.replace(/[^\d]/g,''));
		}			

		function checksubmit(){
			value = $("#sizename").attr("value");
	       	if(value=="0")
	       	{
				parent.hiAlert("<?=$strselectsize;?>", '<?=$strclueinfo;?>');
				$("#sizename").focus();
				return false;
	        }
		}
		
		function addcart()
		{
			$("#addorder").submit(function(){
				return false;
			});
			value = $("#sizename").attr("value");
	       	if(value=="0")
	       	{
				parent.hiAlert("<?=$strselectsize;?>", '<?=$strclueinfo;?>');
				$("#sizename").focus();
				return false;
	        }

			value=$("#txtnum").attr("value");
			if (value==0) {
				hiAlert('<?=$strwritenum;?>', '<?=$strclueinfo;?>');
				$("#txtuserName").focus();
				return false;
			}	

		   	var strSQL = "";                      
		   	strSQL+="iType=1";
		   	strSQL+="&GID="+<?=$GID;?>;
		   	strSQL+="&CID="+<?=$CID;?>;
		   	strSQL+="&SID=";
		   	strSQL+=$("#sizename").attr("value");
		   	strSQL+="&NUM=";
		   	strSQL+=$("#txtnum").attr("value");
		   
		   	$.post("goodsCart.php",strSQL,function(msg)
		   	{
			   	if (msg==-1)
			   	  {	hiAlert('<?=$strerr;?>', '<?=$strclueinfo;?>');
			   	  	$("#sizename").focus();
			   	  	return false;
			   	  }
			   	  
			   	if (msg==1)   
			   	{	

					parent.hiAlert("<?=$straddcart;?>", '<?=$strclueinfo;?>');
					setTimeout('location.reload();parent.$("#popup_ok").click();',3000);
					return false;
					
					//location="cartdetail.php";
				}   
			})        				
		}		
	</script>
	 
</head>
	<body>	
		<?
		include("header.php"); 
		?>

		<div id="body2_all" >
			<div id="body2_h01" ></div>
			
			<div class="body2_div">
				<div class="goodsdetail_a01"> 
					
					<div class="goodsdetail_bigpic">
						<span id="mainimage1"><img style="width:450px;height:300px;" src="<?=$lng_picpath;?>b_<?=$rsgoods["pic1"];?>" border="0" /></span>
						<? if($rsgoods["pic2"]!=""){ ?><span id="mainimage2"><img style="width:300px;" style="width:450px;height:300px;display:none;" src="<?=$lng_picpath;?>b_<?=$rsgoods["pic2"];?>" border="0"/></span><? }?>
						<? if($rsgoods["pic3"]!=""){ ?><span id="mainimage3"><img style="width:300px;" style="width:450px;height:300px;display:none;" src="<?=$lng_picpath;?>b_<?=$rsgoods["pic3"];?>" border="0"/></span><? }?>								
						<? if($rsgoods["pic4"]!=""){ ?><span id="mainimage4"><img style="width:300px;" style="width:450px;height:300px;display:none;" src="<?=$lng_picpath;?>b_<?=$rsgoods["pic4"];?>" border="0"/></span><? }?>				
						<? if($rsgoods["pic5"]!=""){ ?><span id="mainimage5"><img style="width:300px;" style="width:450px;height:300px;display:none;" src="<?=$lng_picpath;?>b_<?=$rsgoods["pic5"];?>" border="0"/></span><? }?>								
						<? if($rsgoods["pic6"]!=""){ ?><span id="mainimage6"><img style="width:300px;" style="width:450px;height:300px;display:none;" src="<?=$lng_picpath;?>b_<?=$rsgoods["pic6"];?>" border="0"/></span><? }?>				
					</div>
					


					<!--img style="float: left;width: 500px;height:300px;margin-top:20px;margin-left:30px;border:0px solid red;" src="<?=$lng_picpath;?><?=$rsgoods["pic"];?>" class="jqzoom"  alt="<?=$lng_picpath;?><?=$rsgoods["pic"];?>" border="0" /-->
					
					<div class="goodsdetail_a04">
						<?
						if ($rsgoods["pic1"]!="")
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?=$rsgoods["pic1"];?>" 
							     onmouseover="$('.goodsdetail_bigpic').cycle(0);" 
							     id="otherimageprd_1" border="0"/>
						<?
						}
						else
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?='no_image.gif';?>" border="0" />
						<?
						}
						?>
						     
						<?
						if ($rsgoods["pic2"]!="")
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?=$rsgoods["pic2"];?>" 
							     onmouseover="$('.goodsdetail_bigpic').cycle(1);" 
							     id="otherimageprd_2" border="0"/>

						<?
						}
						else
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?='no_image.gif';?>" border="0" />
						<?
						}
						?>

						<?
						if ($rsgoods["pic3"]!="")
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?=$rsgoods["pic3"];?>" 
							     onmouseover="$('.goodsdetail_bigpic').cycle(2);" 
							     id="otherimageprd_3" border="0"/>
						<?
						}
						else
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?='no_image.gif';?>" border="0" />
						<?
						}
						?>

						<?
						if ($rsgoods["pic4"]!="")
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?=$rsgoods["pic4"];?>" 
							     onmouseover="$('.goodsdetail_bigpic').cycle(3);" 
							     id="otherimageprd_4" border="0"/>
						<?
						}
						else
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?='no_image.gif';?>" border="0" />
						<?
						}
						?>

						<?
						if ($rsgoods["pic5"]!="")
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?=$rsgoods["pic5"];?>" 
							     onmouseover="$('.goodsdetail_bigpic').cycle(4);" 
							     id="otherimageprd_5" border="0"/>
						<?
						}
						else
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?='no_image.gif';?>" border="0" />
						<?
						}
						?>

						<?
						if ($rsgoods["pic6"]!="")
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?=$rsgoods["pic6"];?>" 
							     onmouseover="$('.goodsdetail_bigpic').cycle(5);" 
							     id="otherimageprd_6" border="0"/>
						<?
						}
						else
						{
						?>
							<img class="goodsdetail_a05" src="<?=$lng_picpath;?><?='no_image.gif';?>" border="0" />
						<?
						}
						?>

					</div>	
				</div>	
				<form action="./goodsorder.php" name="addorder" method="post" id="addorder" onsubmit="return checksubmit()"> 
				<div class="goodsdetail_a02"> 
					<div class="goodsdetail_a07"><?=$strgoodsname;?>: <?=mb_strimwidth($rsgoods["goodsname"], 0, 42,'...');?></div>
					<div class="goodsdetail_a07"><?=$stradviceprice;?>: $<?=$rsgoods["adviceprice"];?>.00</div>
					<div class="goodsdetail_a07"><?=$strColorName;?>: <?=$rsgoods["colorname"];?></div>
					<div class="goodsdetail_a07"><?=$strgoodsid;?>: <?=$rsgoods["goodsid"];?></div>
					<div class="goodsdetail_a09"><?=$strgoodsdetail;?>:</div>
					<div class="goodsdetail_a10"><?=$rsgoods["remark"];?></div>
					<div class="goodsdetail_a09"></div>

					<div class="goodsdetail_a11"><?=$strsize;?>: </div>
					<div id=psizename class="goodsdetail_a11" style="width:120px;">
						<select name="sizename" id="sizename">
							<option value="0" selected="selected"><?='size';?></option>
						<?
							$strSQL= "select * from size where delflag<>'1' and id='".$rsgoods["sizeid"]."' order by id limit 0,1";  

							$db = MySQL::getInstance('','r-w'); 
							$DBR=$db->query($strSQL); 
							$rssize=$db->fetch($DBR)
							
							?>
							<? if ($rssize["size01"]!='') {?><option value="<?=$rssize["size01"];?>"><?=$rssize["size01"];?></option><?}?>
							<? if ($rssize["size02"]!='') {?><option value="<?=$rssize["size02"];?>"><?=$rssize["size02"];?></option><?}?>
							<? if ($rssize["size03"]!='') {?><option value="<?=$rssize["size03"];?>"><?=$rssize["size03"];?></option><?}?>
							<? if ($rssize["size04"]!='') {?><option value="<?=$rssize["size04"];?>"><?=$rssize["size04"];?></option><?}?>
							<? if ($rssize["size05"]!='') {?><option value="<?=$rssize["size05"];?>"><?=$rssize["size05"];?></option><?}?>
							<? if ($rssize["size06"]!='') {?><option value="<?=$rssize["size06"];?>"><?=$rssize["size06"];?></option><?}?>
							<? if ($rssize["size07"]!='') {?><option value="<?=$rssize["size07"];?>"><?=$rssize["size07"];?></option><?}?>
							<? if ($rssize["size08"]!='') {?><option value="<?=$rssize["size08"];?>"><?=$rssize["size08"];?></option><?}?>
							<? if ($rssize["size09"]!='') {?><option value="<?=$rssize["size09"];?>"><?=$rssize["size09"];?></option><?}?>
							<? if ($rssize["size10"]!='') {?><option value="<?=$rssize["size10"];?>"><?=$rssize["size10"];?></option><?}?>
							<? if ($rssize["size11"]!='') {?><option value="<?=$rssize["size11"];?>"><?=$rssize["size11"];?></option><?}?>
							<? if ($rssize["size12"]!='') {?><option value="<?=$rssize["size12"];?>"><?=$rssize["size12"];?></option><?}?>
							<? if ($rssize["size13"]!='') {?><option value="<?=$rssize["size13"];?>"><?=$rssize["size13"];?></option><?}?>
							<? if ($rssize["size14"]!='') {?><option value="<?=$rssize["size14"];?>"><?=$rssize["size14"];?></option><?}?>
							<? if ($rssize["size15"]!='') {?><option value="<?=$rssize["size15"];?>"><?=$rssize["size15"];?></option><?}?>
						</select>
					</div>

					<div class="goodsdetail_a11"><?=$strnum;?>: </div>
					<input type="text" id="txtnum" name="txtnum" value="1" class="textboxnum" onkeyup="ChangeNum();">
					<div class="goodsdetail_a09"></div>
					<div class="goodsdetail_a07" >
						<input type="image" name="addorder" value="addorder" src="images/<?=$lang['strgoodsorder'] ?>" onclick="javascript:" >
						<input type="image" name="addcart" value="addcart" src="images/<?=$lang['strgoodscart'] ?>" onclick="javascript:addcart();" >
						<input type="hidden" name="goodsid" value="<?=$rsgoods["goodsid"];?>" />
						<input type="hidden" name="colorname" value="<?=$rsgoods["colorname"];?>" />
						<input type="hidden" name="GID" value="<?=$GID;?>" />
						<input type="hidden" name="CID" value="<?=$CID;?>" />
						<input type="hidden" name="adviceprice" value="<?=$rsgoods["adviceprice"];?>" />
						<input type="hidden" name="action" value="addorder" />
					</div>
					
				</div>	
				</form>
				
				<div class="goodsdetail_a12">
				    <div class="goodsdetail_a13"><?=$strviewed;?></div>

					<?
					$i=0;
					$uid="";
					
					foreach ($arraystrGID as $iGID) 
					{   
						$i=$i+1;
						if ($i<=6)
						{
						    if ($iGID!='')
						    {
						    	$uid.=$iGID.",";
                    ?> 
							    <div class="goodsdetail_a14">
									<?
									$sql = "select g.id,g.goodsid,g.adviceprice,g.".$strLanguage_Goods.",g.".$strLanguage_GoodsRemark.",g.pic,g.pic1,g.pic2,g.pic3,g.pic4,g.pic5,g.pic6,c.".$strLanguage_Color." ";
									$sql.= "from goods g left join color c on c.id=g.colorid ";
									$sql.= "where g.id='".$iGID."' limit 0,1";
									$db = MySQL::getInstance('','r-w'); 
									$rsView = $db->fetch($db->query($sql));
									?>
							    	<a href="goodsdetail.php?GID=<?=$rsView["id"];?>"><img class="goodsdetail_a15" src="<?=$lng_picpath;?><?=$rsView["pic1"];?>" border="0" /></a>
							    	<div class="goodsdetail_a16"><a href="goodsdetail.php?GID=<?=$rsView["id"];?>"><?=$rsView["goodsname"];?></a></div>	
							    </div>
					<?			    
						    }
						}    
					}  
					$_SESSION["ViewGoodsID"]=$uid;
					?>
				</div>
			</div>	


			<div id="body2_h02" ></div>
		</div>


		<?
		include("footer.php"); 
		?>
	</body>		
</html>